using System;
using System.Collections;
using UniFramework.Event;
using UnityEngine;
using YooAsset;

public partial class Boot:MonoBehaviour
{
    public static Boot Instance;
    [Tooltip("加载游戏入口场景，放在yooasset的DefaltPackage包")]
#if ODIN_INSPECTOR
    [Sirenix.OdinInspector.FilePath(Extensions="unity")]
#endif
    public string entryScene;
    void Awake()
    {
        Instance = this;
#if !UNITY_EDITOR
        if(PlayMode == EPlayMode.EditorSimulateMode)
            PlayMode = EPlayMode.HostPlayMode;
    #if UNITY_WEBGL
        PlayMode = EPlayMode.WebPlayMode;
    #endif
#endif
    }
    
    IEnumerator Start()
    {
        yield return StartYooAsset();
        if (!Application.isEditor)
        {
            //先注入元信息
            yield return LoadMetadataForAOTAssemblies();//hybridclr
            //加载热更新资源
            yield return LoadHotfixAssemblies();//hybridclr
        }
        //事件系统
        UniEvent.Destroy();
        //加载游戏入口场景，放在yooasset的DefaltPackage包
        yield return YooAssets.LoadSceneAsync(entryScene);
    }
}